// 定义食物类food
class Food {
  element: HTMLElement;
  constructor () {
    // 获取food元素将其赋值给element
    this.element = document.getElementById('food')!;
  }

  // 获取食物X坐标
  get X () {
    return this.element.offsetLeft
  }
  // 获取食物Y坐标
  get Y() {
    return this.element.offsetTop
  }
  //修改食物的位置
  change () {
    let top = Math.round(Math.random() * 29) * 10;
    let left = Math.round(Math.random() * 29) * 10;
    this.element.style.left = left + 'px'
    this.element.style.top = top + 'px'
  }
}

export default Food